//
//  XYActivityIndicator.m
//  NemoSDKDemo
//
//  Created by 高超 on 2020/8/7.
//  Copyright © 2020 JackYang. All rights reserved.
//

#import "XYActivityIndicator.h"

@implementation XYActivityIndicator

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)startAnimating {
    self.hidden = NO;
    CAAnimation *animation = [self.layer animationForKey:@"ActivityAnimation"];
    if (!animation)
    {
        CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        animation.fromValue = [NSNumber numberWithFloat:0.0];
        animation.toValue = [NSNumber numberWithFloat: 2* M_PI];
        animation.duration = 1.0;
        animation.repeatCount = CGFLOAT_MAX;
        
        [self.layer addAnimation:animation forKey:@"ActivityAnimation"];
    }
}

- (void)stopAnimating {
    [self.layer removeAllAnimations];
    self.hidden = YES;
}

@end
